package jp.gr.java_conf.yuzu_project.view;

import jp.gr.java_conf.yuzu_project.R;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

/**
 * 背景、立ち絵表示用クラス
 * @author 	ゆずプロジェクト
 *
 */
public class PlaySurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback {

	private int mDispWidth;
	private int mDispHeight;
	private SurfaceHolder mHolder;
	private Context mContext;
	private Canvas canvas;
	
	public PlaySurfaceView(Context context, SurfaceView sv, int dispWidth, int dispHeight) {
		super(context);
		mContext = context;
		mDispWidth = dispWidth;
		mDispHeight = dispHeight;
		mHolder = sv.getHolder();
		mHolder.addCallback(this);
	}
	
	public void run() {
	}

	public void surfaceChanged(SurfaceHolder holder, int arg1format, int width, int height) {
		canvas = holder.lockCanvas();
		canvas.drawColor(Color.BLACK);
		holder.unlockCanvasAndPost(canvas);
		mHolder = holder;
	}

	public void surfaceCreated(SurfaceHolder holder) {
		
	}

	public void surfaceDestroyed(SurfaceHolder holder) {
		
	}
	
	public void chageBackGround(int bgNumber) {
		canvas = mHolder.lockCanvas();
		Resources resource = mContext.getResources();
		Bitmap bitmap = BitmapFactory.decodeResource(resource, R.drawable.bg_sample);
		canvas.drawColor(Color.GREEN);
		mHolder.unlockCanvasAndPost(canvas);
	}

}
